package com.sunny.ynhz.ui.report;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sunny.ynhz.R;
import com.sunny.ynhz.ui.base.AppBaseNoTranslationTitleBarActivity;

public class ChooseAreaActivity extends AppBaseNoTranslationTitleBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_choose_area);
        setTitle("行政区域");
        int type = getIntent().getIntExtra("type", 0);
        LinearLayout ll_area = findViewById(R.id.ll_area);
        if (type == 0) {
            ll_area.getChildAt(0).setVisibility(View.GONE);
        }
        int childCount = ll_area.getChildCount();
        for (int i = 0; i < childCount; i++) {
            final LinearLayout ll_child = (LinearLayout) ll_area.getChildAt(i);
            final TextView tv_child = (TextView) ll_child.getChildAt(0);
            tv_child.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    String tag = ll_child.getTag().toString();
                    Intent intent = new Intent();
                    intent.putExtra("areaCode", tag);
                    intent.putExtra("areaName", tv_child.getText().toString());
                    setResult(RESULT_OK, intent);
                    finish();
                }
            });
        }
    }
}
